package org.asiainfo.ability.base.exception;

import org.asiainfo.ability.base.utils.Response;

/**
 * @Author: visen
 * @Date: 2018/3/21
 * @Description:
 */
public class SystemException extends Exception{
    private String code;
    private String desc;

    public SystemException(Exception cause) {
        super(cause);
    }
    public SystemException(String message, Exception cause) {
        super(message, cause);
    }
    public SystemException(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    public SystemException(String code, String desc, Throwable cause) {
        super(cause);
        this.code = code;
        this.desc = desc;

    }
    public SystemException(String desc) {
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }


    public String buildErrorInfo() {
        if(this.code == null) {
            return this.desc;
        }
        return Response.error(this.code, this.desc);
    }
}
